/*************************************************************************
> File Name: Sport.cpp
> Author: Wu Junqiang
> Mail: 15769154659@163.com
> Created Time: 2018年01月23日 星期二 15时06分18秒
> Note: SportData   user Data class
************************************************************************/
#include "Sport.h"

Sport::Sport()
{
	instance = DataMgr::instance();
}

Sport::~Sport()
{
}

list<SportData> Sport::querySportdata(string name)
{
	if(name.empty())
	{
		cout << "invalid name 1!!" << endl;
	}
	if(instance->canRegister(name))
	{
		list<SportData> sportdata;
		sportdata = instance->QueryuserSportData(name);
		return sportdata;
	}
	else
	{
		cout << "have no this user, Please add user!!" << endl;
	}
}
//按名字和性别查询　　　　　未完成
list<SportData> Sport::querySportdata(string name, string sex)
{
	list<SportData> sportdata;
	return sportdata;
}

bool Sport::SaveSportdata(SportData data)
{
	if (data.name.empty() || data.sportClass.empty() || data.mac.empty() || data.sportTime.empty() || data.group.empty() || data.groupNum.empty() || data.info.empty())
	{
		cout << "insert data is invalid!!! " << endl;
		return false;
	}
	else
	{
		if(instance->SaveuserSportDate(data))
		{
            cout << "用户数据保存成功" << endl;
			return true;
		}
		else
		{
//            cout << "用户数据保存失败"　<< endl;
			return false;
		}
	}	
	return false;
}
